﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Eneta.Portal.Forum.Rss
{
    [Serializable]
    public abstract class RssModule
    {
        // Fields
        private ArrayList _alBindTo = new ArrayList();
        private RssModuleItemCollection _rssChannelExtensions = new RssModuleItemCollection();
        private RssModuleItemCollectionCollection _rssItemExtensions = new RssModuleItemCollectionCollection();
        private string _sNamespacePrefix = "";
        private Uri _uriNamespaceURL = RssDefault.Uri;

        // Methods
        public void BindTo(int channelHashCode)
        {
            this._alBindTo.Add(channelHashCode);
        }

        public bool IsBoundTo(int channelHashCode)
        {
            return (this._alBindTo.BinarySearch(0, this._alBindTo.Count, channelHashCode, null) >= 0);
        }

        // Properties
        internal RssModuleItemCollection ChannelExtensions
        {
            get
            {
                return this._rssChannelExtensions;
            }
            set
            {
                this._rssChannelExtensions = value;
            }
        }

        internal RssModuleItemCollectionCollection ItemExtensions
        {
            get
            {
                return this._rssItemExtensions;
            }
            set
            {
                this._rssItemExtensions = value;
            }
        }

        public string NamespacePrefix
        {
            get
            {
                return this._sNamespacePrefix;
            }
            set
            {
                this._sNamespacePrefix = RssDefault.Check(value);
            }
        }

        public Uri NamespaceURL
        {
            get
            {
                return this._uriNamespaceURL;
            }
            set
            {
                this._uriNamespaceURL = RssDefault.Check(value);
            }
        }
    }
}
